<fieldset>
    <legend>
        <% if params[:search].nil? %>
        List of invoices
        <% else %>
        List of invoices: Search result
        <% end %>
    </legend>
    
    <p class="p_new">
        <%= link_to [image_tag("add.png", :class=>"newitem", :alt=>"New invoice", :title=>"New invoice"),'New invoice'], {:action => 'new'}, :class=>"newitem" %>
    </p>
    <hr/> 
    
    <table class="standard">
        <tr>
            <th>Name</th>
            <th>Client</th>
            <th>Created</th>
            <th>Issued</th>
        </tr>
        
        <% for invoice in @invoices %>
        <tr>
            <td><%=h invoice.name %></td>
            <td><%=h invoice.client.name %></td>
            <td><%=h invoice.created_at.strftime("%d/%m/%y") %></td>
            <td><%= invoice.issued_at ? h(invoice.issued_at.strftime("%d/%m/%y")) : "-" %></td>
            
            <td>
                <%= link_to image_tag("show.png", :alt=>"Show", :title=>"Show"), {:action => 'show', :id => invoice}, :class=>"nobg"%>       
            </td>
            <td>
                <%= link_to image_tag("edit.png", :alt=>"Edit", :title=>"Edit"), {:action => 'edit', :id => invoice}, :class=>"nobg"%>
            </td>
            <td>
                <%= link_to image_tag("issue.png", :alt=>"Issue", :title=>"Issue"), {:action => 'issue', :id => invoice}, :class=>"nobg", :confirm => "Issuing an invoice causes that activities will not be editable and it is irreversible. Are you sure?"  unless invoice.is_issued %>
            </td>
        </tr>
        <% end %>
    </table>
    
    <%= paginate_me @invoices %>
</fieldset>